package yxy.game.pm2.bean.module.rank.openserviceactive;

import org.joda.time.DateTime;
import yxy.game.pm2.bean.module.rank.RankModule;

/**
 * @ClassName OpenServiceRushRank
 * @Author jingtao-zheng
 * @Date 2022/7/6 17:35
 * @Version 1.0
 **/
public abstract class OpenServiceRushRank extends RankModule {

    private int areaId;
    private int type;


    public OpenServiceRushRank(int areaId, int type) {
        this.type = type;
        this.areaId = areaId;
        initInfo();
    }

    @Override
    public String rankName() {
        return "OSRUSH:";
    }

    @Override
    protected String rankKey() {
        return String.format("AREA:%s:RANK:%s", this.areaId, rankActiveName());
    }

    public String rankActiveName() {
        return rankName() + this.type;
    }

    /**
     * 让排行榜具有时间属性，并且实时排序
     * 14-19位按真实score排名，1-13位按时间排序
     * 理论真实score所存业务值不要超过999999
     *
     * @param value 真实score值
     * @return long zset要存储的score
     */
    @Override
    protected long valuePlastic(long value) {
        return value * 10000000000000L + (10000000000000L - DateTime.now().getMillis());// 13位时间戳长度
    }

    /**
     * @return long 真实score
     */
    @Override
    protected long valueRestore(long score) {
        return score / 10000000000000L;
    }

    protected boolean reconsitution() {
        return false;
    }

}
